package modelo.hibernate.config;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.*;
//import org.hibernate.cfg.*;

public class Sesion {
		
		 private static final SessionFactory sessionFactory;
		    static {
		       
		      AnnotationConfiguration cfg2 = new AnnotationConfiguration();
		       
		        try { 
		            System.out.println("paso por aqui");
		        	sessionFactory = cfg2.configure("hibernate.cfg.xml").buildSessionFactory();
		        	//	sessionFactory = cfg2.configure(new File("hibernate.cfg.xml")).buildSessionFactory();
		          
		        } catch (Throwable ex) {
		            ex.printStackTrace();
		            throw new ExceptionInInitializerError(ex);
		        }

		    }

		    public static Session openSession() throws HibernateException {
		        return sessionFactory.openSession();
		    }

	}
